function fileController(){
   
    this.saveImage = function(canvas, path, success, error){
        var url = "http://aleonlinespot.altervista.org/edit.php";
        var patt = /\.[0-9a-z]+$/i;
        var ext = path.match(patt).toString().substr(1).toLowerCase();
        console.log("ext: "+ext);
        var data_url = canvas.toDataURL('image/'+ext);
        console.log(data_url.toString().substr(0, 30));
        var params = {
            path: path,
            contents: data_url
        };

        $.post(url, params, function(data){
            //window.alert("post response: "+data);
            if (data == "Unable to save the file."){
                error();
            }
            else{
                success();
            }
        }, 'html'); 
   
    }
}
